package com.sinochem.sales.common.exception;

import com.sinochem.sales.common.entity.Result;

/**
 * @author xuan😴🐶🐱🐽🌺  <a href="zhangshixuanj@163.com">联系作者</a>
 * @version Revision:v1.0,Date: 2018/4/23 10:09
 * @project parent
 * @description
 * @Modification Date: 2018/4/23 10:09  {填写修改说明}
 */
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /*返回对象*/
    private Result result;

    public BusinessException(Result result) {
        super(result.getError().getMsg());
        this.result = result;
    }

    public BusinessException(String message) {
        super(message);
        this.result = Result.error(message);
    }

    public BusinessException(String code,String message) {
        super(message);
        this.result = new Result(new Error(code,message));
    }

    public BusinessException(String message, Exception e) {
        super(message);
        this.result = Result.error(message);
    }

    public Result getResult() {
        return result;
    }

    public void setResult(Result result) {
        this.result = result;
    }
}
